package com.ease.framework.gef4p.figures.impl {
   import com.ease.framework.gef4p.figures.IAnnotationFigure;
   import com.ease.framework.gef4p.figures.ILabelFigure;

   import flash.display.DisplayObject;

   import mx.core.ScrollPolicy;
   import mx.core.UIComponent;

   public class AnnotationFigure extends ArtifactFigure implements IAnnotationFigure {
      //private var labelShow:ILabelFigure; //显示label的对象

      public function AnnotationFigure() {
         super();
         this.width = 120;
         this.height = 80;
         this.clipContent = false;

         this.verticalScrollPolicy = ScrollPolicy.OFF;
         this.horizontalScrollPolicy = ScrollPolicy.OFF;

         this.getLabelFigure().width = this.width;
         this.getLabelFigure().height = this.height;
         this.getLabelFigure().editWidth = this.width;
         this.getLabelFigure().editHeight = this.height;
      }

      override protected function createChildren():void {
         super.createChildren();

         var labelShow:ILabelFigure = this.getLabelFigure();
         this.addChild(labelShow as DisplayObject);

         //var point:Point = this.localToGlobal( new Point(0,0));
         labelShow.x = 0;
         labelShow.y = 0;

         //labelShow.editX = point.x;
         //labelShow.editY = point.y;
         labelShow.width = this.width;
         labelShow.height = this.width;


      }

      override public function getLabelFigure():ILabelFigure {
         if (labelFigure == null) {
            setLabelFigure(new AnnotationLabelFigure());
         }
         return labelFigure;
      }

      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
         super.updateDisplayList(unscaledWidth, unscaledHeight);

         var labelShow:ILabelFigure = this.getLabelFigure();
         //var point:Point = this.localToGlobal( new Point(0,0));

         labelShow.width = this.width;
         labelShow.height = this.height;
         //labelShow.editX = point.x;
         //labelShow.editY = point.y;
         labelShow.editWidth = this.width;
         labelShow.editHeight = this.height;

         UIComponent(labelShow).validateNow();

         graphics.clear();
         graphics.lineStyle(1, 0x9EB3A0);
         graphics.beginFill(0xFFFFE4, 0.9);
         graphics.drawRoundRect(0, 0, this.width, this.height, 0, 0);
         graphics.endFill();

      }

   }
}